<script setup name="Profile">
import UserAvatar from './userAvatar'
import ResetPwd from './resetPwd'
import UserInfo from "@/views/system/user/profile/userInfo.vue";
import { getUserProfile } from '@/api/system/user'

const activeTab = ref('resetPwd')
const state = reactive({
  user: {},
  roleGroup: {},
  postGroup: {},
})

function getUser() {
  getUserProfile().then((response) => {
    state.user = response.data
    state.roleGroup = response.roleGroup
    state.postGroup = response.postGroup
  })
};

getUser()
</script>

<template>
  <div class="app-container">
    <ElRow :gutter="20">
      <ElCol :span="6" :xs="24">
        <ElCard class="box-card">
          <template #header>
            <div class="clearfix">
              <span>个人信息</span>
            </div>
          </template>
          <div>
            <div class="text-center">
              <UserAvatar />
            </div>
            <ul class="list-group list-group-striped">
              <li class="list-group-item">
                <SvgIcon icon-class="user" />登录账号
                <div class="pull-right">
                  {{ state.user.userName }}
                </div>
              </li>
              <li class="list-group-item">
                <SvgIcon icon-class="phone" />手机号码
                <div class="pull-right">
                  {{ state.user.phonenumber }}
                </div>
              </li>
              <!--              <li class="list-group-item"> -->
              <!--                <SvgIcon icon-class="email" />用户邮箱 -->
              <!--                <div class="pull-right"> -->
              <!--                  {{ state.user.email }} -->
              <!--                </div> -->
              <!--              </li> -->
              <!--              <li class="list-group-item"> -->
              <!--                <SvgIcon icon-class="tree" />所属部门 -->
              <!--                <div v-if="state.user.dept" class="pull-right"> -->
              <!--                  {{ state.user.dept.deptName }} / {{ state.postGroup }} -->
              <!--                </div> -->
              <!--              </li> -->
              <li class="list-group-item">
                <SvgIcon icon-class="peoples" />所属角色
                <div class="pull-right">
                  {{ state.roleGroup }}
                </div>
              </li>
              <li class="list-group-item">
                <SvgIcon icon-class="date" />创建日期
                <div class="pull-right">
                  {{ state.user.createTime }}
                </div>
              </li>
            </ul>
          </div>
        </ElCard>
      </ElCol>
      <ElCol :span="18" :xs="24">
        <ElCard>
          <template #header>
            <div class="clearfix">
              <span>基本资料</span>
            </div>
          </template>
          <ElTabs v-model="activeTab">
<!--            基本资料部分之前是要删除的-->
                        <ElTabPane label="基本资料" name="userinfo">
                          <UserInfo :user="state.user" />
                        </ElTabPane>
            <ElTabPane label="修改密码" name="resetPwd">
              <ResetPwd />
            </ElTabPane>
          </ElTabs>
        </ElCard>
      </ElCol>
    </ElRow>
  </div>
</template>
